package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.danmo.domain.DanmoGalleryWorksPictures;
import com.muyu.danmo.service.IDanmoGalleryWorksPicturesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 画廊作品图片Controller
 *
 * @author yangle
 * @date 2024-10-23
 */
@RestController
@RequestMapping("/galleryWorksPictures")
public class DanmoGalleryWorksPicturesController extends BaseController
{
    @Autowired
    private IDanmoGalleryWorksPicturesService danmoGalleryWorksPicturesService;

    /**
     * 查询画廊作品图片列表
     */
//    @RequiresPermissions("system:galleryWorksPictures:list")
    @GetMapping("/list")
    public Result<TableDataInfo<DanmoGalleryWorksPictures>> list(DanmoGalleryWorksPictures danmoGalleryWorksPictures)
    {
        startPage();
        List<DanmoGalleryWorksPictures> list = danmoGalleryWorksPicturesService.selectDanmoGalleryWorksPicturesList(danmoGalleryWorksPictures);
        return getDataTable(list);
    }

    /**
     * 导出画廊作品图片列表
     */
//    @RequiresPermissions("system:galleryWorksPictures:export")
    @Log(title = "画廊作品图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoGalleryWorksPictures danmoGalleryWorksPictures)
    {
        List<DanmoGalleryWorksPictures> list = danmoGalleryWorksPicturesService.selectDanmoGalleryWorksPicturesList(danmoGalleryWorksPictures);
        ExcelUtil<DanmoGalleryWorksPictures> util = new ExcelUtil<DanmoGalleryWorksPictures>(DanmoGalleryWorksPictures.class);
        util.exportExcel(response, list, "画廊作品图片数据");
    }

    /**
     * 获取画廊作品图片详细信息
     */
//    @RequiresPermissions("system:galleryWorksPictures:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoGalleryWorksPicturesService.selectDanmoGalleryWorksPicturesById(id));
    }

    /**
     * 新增画廊作品图片
     */
//    @RequiresPermissions("system:galleryWorksPictures:add")
    @Log(title = "画廊作品图片", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoGalleryWorksPictures danmoGalleryWorksPictures)
    {
        return toAjax(danmoGalleryWorksPicturesService.insertDanmoGalleryWorksPictures(danmoGalleryWorksPictures));
    }

    /**
     * 修改画廊作品图片
     */
//    @RequiresPermissions("system:galleryWorksPictures:edit")
    @Log(title = "画廊作品图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoGalleryWorksPictures danmoGalleryWorksPictures)
    {
        return toAjax(danmoGalleryWorksPicturesService.updateDanmoGalleryWorksPictures(danmoGalleryWorksPictures));
    }

    /**
     * 删除画廊作品图片
     */
//    @RequiresPermissions("system:galleryWorksPictures:remove")
    @Log(title = "画廊作品图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoGalleryWorksPicturesService.deleteDanmoGalleryWorksPicturesByIds(ids));
    }
}
